package com.swpu.project.controller;


import com.swpu.project.common.BaseResponse;
import com.swpu.project.model.entity.NonHeavyMetal;
import com.swpu.project.service.INonHeavyMetalService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author swpuyanxiegroup1
 * @since 2024-07-29
 */
@RestController
@RequestMapping("/data")
public class NonHeavyMetalController {
    @Resource
    INonHeavyMetalService iNonHeavyMetalService;




    @GetMapping("/nonheavy/query/{id}")
    BaseResponse queryData(@PathVariable(name="id") String belongId)
    {
         return iNonHeavyMetalService.queryData(belongId);
    }


    @PutMapping("/nonheavy/update")
    BaseResponse updateNonHeavy(@RequestBody List<NonHeavyMetal> nonHeavyMetals)
    {


        return BaseResponse.iFSuccess(iNonHeavyMetalService.updateBatchById(nonHeavyMetals));




    }
    @PutMapping("/nonheavy/updatesingle")
       BaseResponse updateNonheavy(NonHeavyMetal nonHeavyMetal)
    {    return BaseResponse.iFSuccess(iNonHeavyMetalService.updateById(nonHeavyMetal));

    }
  @DeleteMapping("/nonheavy/delete")
    BaseResponse deleteNonHaevy(@PathVariable(name = "id") String id)
  {
      iNonHeavyMetalService.lambdaUpdate().set(NonHeavyMetal::getData,"0.0")
              .eq(NonHeavyMetal::getDataId,id).update();


      return BaseResponse.ok();


  }


}
